// ========================
// RSDK Project Sonic CD's scrapped rounds
// Script Name: Wheel
// ========================

// ========================
// Aliases
// ========================

#alias Object.Value0	:	Object.Timer
#alias Object.Value1	:	Object.Stood
#alias Object.Value2	:	Object.FrameValue

#alias Object[19].Value0	:	Setup.Belt
#alias Object[19].Value1	:	Setup.PaletteTimer

#alias Object.PropertyValue		:	PushButton.Pressed	

// Priority
#alias 1	:	PRIORITY_ACTIVE

// ========================
// Subs
// ========================

sub ObjectMain
	if PushButton[-1].Pressed == false
		Object.Stood = false
	end if
	
	if Object.Stood == false
		if PushButton[-1].Pressed == true
			if Setup.Belt == 0
				Setup.Belt = 1
			else
				Setup.Belt = 0
			end if
			Object.Stood = true
		end if
	end if
	
	if Setup.PaletteTimer == 0
		if Setup.Belt == 0
			Object.FrameValue++
		end if
	end if

	if Setup.PaletteTimer == 0
		if Setup.Belt == 1
			Object.FrameValue--
		end if
	end if
	
	if Object.FrameValue < 0
		Object.FrameValue = 3
	end if

	if Object.FrameValue > 3
		Object.FrameValue = 0
	end if
end sub

sub ObjectDraw
	DrawSprite(Object.FrameValue)
end sub


sub ObjectStartup
	LoadSpriteSheet("R4.5/Objects.gif")
	SpriteFrame(-16, -16, 32, 32, 1, 122)
	SpriteFrame(-16, -16, 32, 32, 1, 188)
	SpriteFrame(-16, -16, 32, 32, 1, 155)
	SpriteFrame(-16, -16, 32, 32, 1, 221) 

	ArrayPos0 = 32
	while ArrayPos0 < 1056
		if Object[ArrayPos0].Type == TypeName[Wheel]
			Object[ArrayPos0].Priority  = PRIORITY_ACTIVE
			Object[ArrayPos0].DrawOrder = 4
		end if
		ArrayPos0++
	loop
end sub

// ========================
// Editor Subs
// ========================

sub RSDKDraw
	DrawSprite(0)
end sub


sub RSDKLoad
	LoadSpriteSheet("R4.5/Objects.gif")
	SpriteFrame(-16, -16, 32, 32, 1, 122)		// #0 - Wheel
	
	SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
end sub
